from ninja import Router
from utils.cj_response import SuccessResponse, ErrorResponse
from utils.list_to_tree import list_to_route
from system.models import Menu

router = Router()


@router.get("/menu/route/tree")
def route_menu_tree(request):
    """
    用于前台获取菜单
    :param request:
    :return:
    """
    queryset = Menu.objects.filter(status=1).values()
    menu_tree = list_to_route(list(queryset))
    return SuccessResponse(data=menu_tree)
